aboutsummaryrefslogtreecommitdiff
path: root/pages/api/consumet/episode/[id].js
diff options
context:
space:
mode:
Diffstat (limited to 'pages/api/consumet/episode/[id].js')
-rw-r--r--pages/api/consumet/episode/[id].js12
1 files changed, 9 insertions, 3 deletions
diff --git a/pages/api/consumet/episode/[id].js b/pages/api/consumet/episode/[id].js
index 737292f..e6f40ce 100644
--- a/pages/api/consumet/episode/[id].js
+++ b/pages/api/consumet/episode/[id].js
@@ -7,12 +7,18 @@ export default async function handler(req, res) {
try {
const id = req.query.id;
const dub = req.query.dub || false;
+ const refresh = req.query.refresh || false;
const providers = ["enime", "gogoanime"];
const datas = [];
const cached = cacheData.get(id + dub);
- if (cached) {
+
+ if (refresh) {
+ cacheData.del(id + dub);
+ }
+
+ if (!refresh && cached) {
return res.status(200).json(cached);
} else {
async function fetchData(provider) {
@@ -31,7 +37,7 @@ export default async function handler(req, res) {
}
return res.json();
});
- if (data.episodes?.length > 0) {
+ if (data.episodes.length > 0) {
datas.push({
providerId: provider,
episodes: dub ? data.episodes : data.episodes.reverse(),
@@ -53,7 +59,7 @@ export default async function handler(req, res) {
if (datas.length === 0) {
return res.status(404).json({ message: "Anime not found" });
} else {
- cacheData.put(id + dub, { data: datas }, 1000 * 60 * 60 * 15); // 15 minutes
+ cacheData.put(id + dub, { data: datas }, 1000 * 60 * 60 * 10);
res.status(200).json({ data: datas });
}
}